<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="UTF-8">
    <title>商品管理</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
<body>
<div th:insert="~{public/publicTop::admintop}"></div>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>商品管理</legend>
</fieldset>

<div class="layui-form" style="margin: auto;width: 80%">
    <table class="layui-table">
        <<!--colgroup>
            <col width="150">
            <col width="150">
            <col width="200">
            <col>
        </colgroup>-->
        <thead>
            <tr>

                <th>商品名</th>
                <th>图片</th>
                <th>单价</th>
                <th>颜色</th>
                <th>状态</th>
                <th>余量</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="good:${goods}">
                <form th:action="@{/admin/updateGood}">
                    <td >
                        <input type="hidden" th:value="${good.getId()}" name="id">
                        <label>
                            <input type="text" th:value="${good.getName()}" name="name">
                        </label>
                    </td>
                    <td> <img th:src="@{'/img/'+${good.getMainimg()}}"> </td>
                    <td >
                        <label>
                            <input type="text" th:value="${good.getPrice()}" name="price">
                        </label>
                    </td>
                    <td >
                        <label>
                            <input type="text" th:value="${good.getColor()}" name="color">
                        </label>
                    </td>
                    <td  th:text="${good.getGstate() == '1'?'在售':'下架'}">
                    </td>
                    <td >
                        <label>
                            <input type="text" th:value="${good.getSum()}" name="sum">
                        </label>
                    </td>
                    <td>
                        <input class="layui-btn" type="submit" value="提交">
                        <a th:if="${good.getGstate() == '0'}" class="layui-btn" th:href="@{'/admin/shelves/'+${good.getId()}}"> 上架(库存为0自动归1) </a>
                        <a th:if="${good.getGstate() == '1'}" class="layui-btn" th:href="@{'/admin/up/'+${good.getId()}}"> 下架 </a>
                        <a class="layui-btn" th:href="@{'/admin/delGood/'+${good.getId()}}">删除</a>
                    </td>
                </form>
            </tr>
            <a class="layui-btn" th:href="@{/admin/toadd}">+ 添加商品</a>
        </tbody>
    </table>
</div>
</body>
</html>